<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  const compose = (...fns) => (arg) =>
    fns.reduceRight((acc, fn) => (fn ? fn(acc) : acc), arg)

  const add = (num1) => (num2) => num1 + num2
  const multiply = (num1) => (num2) => num1 * num2
  const subtract = (num1) => (num2) => num1 - num2

  const composedOperations = compose(add(5), multiply(2), subtract(3))

  const compute = (arr, initialNum = 0) =>
    arr.reduce((acc, val) => composedOperations(acc), initialNum)

  console.log(compute([-10, 25, 55, 22], 6))
</script>
</body>
</html>